// pages/addto/addto.js
var QQMapWX = require('../../qqmap-wx-jssdk1.2/qqmap-wx-jssdk');
var qqmapsdk;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    openid:'',
    Address:'',
    sss:'',
    hiddenName:true,
  },
  get:function(){
    var that= this;
    wx.getStorage({
      key: 'key',
      success:(res)=>{
        that.setData({
          HeadUrl:res.data.avatarUrl,
          NickName:res.data.nickName
        })
        that.onShow();
        console.log(that.data.openid);
      }
    })
  },
  locion(){//位置
    var that=this
    wx.getLocation({
      type: 'gcj02',
      success: function (res) {
        var latitude = res.latitude
        var longitude = res.longitude
        var speed = res.speed
        var accuracy = res.accuracy
      }
    })
    wx.chooseLocation({
      // success: function (res) {
      //   var Address =res.Address
      //   var latitude = res.latitude
      //   var longitude = res.longitude
      //   var speed = res.longitude
      //   var accuracy = res.accuracy
      //   that.setData({latitude: latitude})
      //   that.setData({ longitude: longitude})
      //   that.setData({ longitude:Address })
      // }
      success:(res)=>{
        if(res.address){
          that.setData({
            Address:res.name,
            sss:res.address,
            latitude:res.latitude,
            longitude:res.longitude
          })
        }
        // console.log(res);
        // console.log(that.data);
      }
    })
  },
  ddd:function(data) {//添加数据
    // console.log(data);
    wx.showModal({
      title: '提示',
      content: '您确定提交数据吗？',
      doctor:'',
      success (res) {
        // console.log(res);
        if (res.confirm) {
          console.log('用户点击确定')
          console.log(data)
          var e_name= data.detail.value.e_name
          var e_quantity=data.detail.value.e_quantity
          var e_person=data.detail.value.e_person
          var e_class=data.detail.value.e_class
          var c_phone=data.detail.value.c_phone
          var e_address=data.detail.value.e_address
          var openid=data.detail.value.openid
          wx.request({
            url: 'http://81.68.242.50/index.php/admin/ifi/index?cist=equ_ins', //接口地址
            method:'POST',//传输方式
            data: {
              e_name:e_name,
              e_valuation:e_valuation,
              e_quantity:e_quantity,
              e_person:e_person,
              e_class:e_class,
              c_phone:c_phone,
              e_address:e_address,
              openid:openid,
            },
            success (res) {//回调函数
              console.log(res.data)
              if (res.data.code=="1") {
                wx.showToast({
                  title: '成功',
                  icon: 'success',
                  duration: 2000
                })
                wx.reLaunch({
                  url: '/pages/release/release',
                })
              }
            }
          })
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
  },
  // submit(){

  // },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    wx.getStorage({
      key: 'open',
      success:(res)=>{
        console.log(res);
        that.setData({
          openid:res.data,
        })
        // that.onShow();
        // console.log(that.data.openid);
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})